package JZOffer;

// 反转链表
public class JzOffer24 {
    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        ListNode node = null;
        ListNode cur = head;
        ListNode curNext = cur.next;

        while (curNext != null) {
            curNext = cur.next;
            cur.next = node;
            node = cur;
            cur = curNext;
        }
        return node;
    }
}
